//
//  ZZCarDebtDetailVC.m
//  新项目
//
//  Created by liGordon on 17/3/16.
//  Copyright © 2017年 刘耀宗. All rights reserved.
//

#import "ZZCarDebtDetailVC.h"
#import "ZZCarDebtDetailCell.h"
static NSString * identifier = @"carDebtDetailCell";
@interface ZZCarDebtDetailVC ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *menuTable;

@end

@implementation ZZCarDebtDetailVC

- (void)viewDidLoad {
    [super viewDidLoad];
    _menuTable.delegate = self;
    _menuTable.dataSource = self;
    self.title = @"单车欠款排行";
    [_menuTable registerNib:[UINib nibWithNibName:@"ZZCarDebtDetailCell" bundle:nil]forCellReuseIdentifier:identifier];
    _menuTable.separatorStyle = UITableViewCellSeparatorStyleNone;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (self.flag==1 || self.flag == 2) {
        return 9;
    }else if (self.flag==3||self.flag == 4)
    {
        return 5;
        
    }else if (self.flag==5)
    {
        return 9;
        
    }else if (self.flag==6){
        return 20;
    }
    else
        return 0;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    ZZCarDebtDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    //根据不同类型进行判别
    [self jugeFlagWithTableView:indexPath andCell:cell];

    return cell;
}

// 判别如何展示
-(void)jugeFlagWithTableView:(NSIndexPath *)indexPath  andCell:(ZZCarDebtDetailCell *)cell
{
    if (self.flag==1||self.flag == 2) {
        if (indexPath.row == 0) {
            cell.titleName.text = @"车牌号";
            cell.detailName.text = self.dic[@"PlateNumber"];
        }else if (indexPath.row == 1){
            cell.titleName.text = @"车主姓名";
            cell.detailName.text = self.dic[@"CarOwner"];
        }else if (indexPath.row == 2){
            cell.titleName.text = @"车型";
            cell.detailName.text =self.dic[@"MakeName"];
        }else if (indexPath.row == 3){
            cell.titleName.text = @"联系电话";
            cell.detailName.text = self.dic[@"CarOwnerTel"];
        }else if (indexPath.row == 4){
            cell.titleName.text = @"总维修次数";
            cell.detailName.text =self.dic[@"ReapirNum"];
            
        }else if (indexPath.row == 5){
            cell.titleName.text = @"总费用";
            cell.detailName.text =[NSString stringWithFormat:@"¥%.2lf",[self.dic[@"AlreadyMoney"] floatValue]];
        }else if (indexPath.row == 6){
            cell.titleName.text = @"当前欠款";
            cell.detailName.text =[NSString stringWithFormat:@"¥%.2lf",[self.dic[@"Arrears"] floatValue]];
        }else if (indexPath.row == 7){
            cell.titleName.text = @"最后保修日期";
            cell.detailName.text =self.dic[@"RepairTime"];
        }else if (indexPath.row == 8){
            cell.titleName.text = @"服务顾问";
            cell.detailName.text = self.dic[@"ServiceConsultant"];
        }
    }else if (self.flag == 3){
        if (indexPath.row == 0) {
            cell.titleName.text = @"维修项目";
            cell.detailName.text = self.dic[@"RepairProject"];
        }else if (indexPath.row == 1){
            cell.titleName.text = @"主修人";
            cell.detailName.text = self.dic[@"Major"];
        }else if (indexPath.row == 2){
            cell.titleName.text = @"工人工时费";
            cell.detailName.text =[NSString stringWithFormat:@"¥%@",self.dic[@"WorkHoursMoney"]];
        }else if (indexPath.row == 3){
            cell.titleName.text = @"提成金额";
            cell.detailName.text = [NSString stringWithFormat:@"¥%@",self.dic[@"RoyaltyAmount"]];
        }else if (indexPath.row == 4){
            cell.titleName.text = @"毛利率";
            cell.detailName.text = [NSString stringWithFormat:@"¥%@",self.dic[@"GrossMargin"]];
            
        }
    }else if(self.flag == 4){
        // 工种利润排行
        if (indexPath.row == 0) {
            cell.titleName.text = @"工种";
            cell.detailName.text = self.dic[@"TypeOfWork"];
        }else if (indexPath.row == 1){
            cell.titleName.text = @"主修人";
            cell.detailName.text = self.dic[@"Major"];
        }else if (indexPath.row == 2){
            cell.titleName.text = @"工人工时费";
            cell.detailName.text = [NSString stringWithFormat:@"¥%@",self.dic[@"WorkHoursMoney"]];
        }else if (indexPath.row == 3){
            cell.titleName.text = @"提成金额";
            cell.detailName.text = [NSString stringWithFormat:@"¥%@",self.dic[@"RoyaltyAmount"]];
        }else if (indexPath.row == 4){
            cell.titleName.text = @"毛利率";
            cell.detailName.text = [NSString stringWithFormat:@"¥%@",self.dic[@"GrossMargin"]];
            
        }

    }else if (self.flag == 5){
        // 商品利润排行
        if (indexPath.row == 0) {
            cell.titleName.text = @"配件ID";
            cell.detailName.text = self.dic[@"PartsID"];
        }else if (indexPath.row == 1){
            cell.titleName.text = @"配件名称";
            cell.detailName.text = self.dic[@"PartsName"];
        }else if (indexPath.row == 2){
            cell.titleName.text = @"配件编码";
            cell.detailName.text =self.dic[@"PartsCode"];
        }else if (indexPath.row == 3){
            cell.titleName.text = @"单位";
            cell.detailName.text = self.dic[@"UnitName"];
        }else if (indexPath.row == 4){
            cell.titleName.text = @"数量";
            cell.detailName.text =self.dic[@"Num"];
            
        }else if (indexPath.row == 5){
            cell.titleName.text = @"总进价";
            cell.detailName.text = [NSString stringWithFormat:@"¥%@",self.dic[@"SumBid"]];
        }else if (indexPath.row == 6){
            cell.titleName.text = @"卖价";
            cell.detailName.text = [NSString stringWithFormat:@"¥%@",self.dic[@"Price"]];
            
        }else if (indexPath.row == 7){
            cell.titleName.text = @"毛利";
            cell.detailName.text = [NSString stringWithFormat:@"¥%@",self.dic[@"GrossProfit"]];
            
        }else if (indexPath.row == 8){
            cell.titleName.text = @"毛利率";
            cell.detailName.text = [NSString stringWithFormat:@"¥%@",self.dic[@"GrossMargin"]];
            
        }

    }else if (self.flag == 6){
        //维修成本核算
        if (indexPath.row == 0) {
            cell.titleName.text = @"维修编号";
            cell.detailName.text = self.dic[@"RepairsNo"];
        }else if (indexPath.row == 1){
            cell.titleName.text = @"车牌号";
            cell.detailName.text = self.dic[@"PlateNumber"];
        }else if (indexPath.row == 2){
            cell.titleName.text = @"车主";
            cell.detailName.text =self.dic[@"CarOwner"];
        }else if (indexPath.row == 3){
            cell.titleName.text = @"车型";
            cell.detailName.text = self.dic[@"MakeName"];
        }else if (indexPath.row == 4){
            cell.titleName.text = @"车主电话";
            cell.detailName.text =self.dic[@"CarOwnerTel"];
            
        }else if (indexPath.row == 5){
            cell.titleName.text = @"服务顾问";
            cell.detailName.text = self.dic[@"ServiceConsultant"];
        }else if (indexPath.row == 6){
            cell.titleName.text = @"应收费";
            cell.detailName.text = [NSString stringWithFormat:@"¥%@",self.dic[@"Chargeable"]];
            
        }else if (indexPath.row == 7){
            cell.titleName.text = @"材料费";
            cell.detailName.text = [NSString stringWithFormat:@"¥%@",self.dic[@"CostOfMaterials"]];
            
        }else if (indexPath.row == 8){
            cell.titleName.text = @"材料成本";
            cell.detailName.text = [NSString stringWithFormat:@"¥%@",self.dic[@"MaterialCost"]];
            
        }else if (indexPath.row == 9){
            cell.titleName.text = @"材料利润";
            cell.detailName.text =[NSString stringWithFormat:@"¥%@",self.dic[@"MaterialProfit"]];
            
        }else if (indexPath.row == 10){
            cell.titleName.text = @"工时费";
            cell.detailName.text = [NSString stringWithFormat:@"¥%@",self.dic[@"WorkHoursMoney"]];
            
        }else if (indexPath.row == 11){
            cell.titleName.text = @"工时成本";
            cell.detailName.text = [NSString stringWithFormat:@"¥%@",self.dic[@"WorkHoursCost"]];
            
        }else if (indexPath.row == 12){
            cell.titleName.text = @"工时利润";
            cell.detailName.text = [NSString stringWithFormat:@"¥%@",self.dic[@"WorkHoursProfit"]];
            
        }else if (indexPath.row == 13){
            cell.titleName.text = @"总优惠";
            cell.detailName.text = [NSString stringWithFormat:@"¥%@",self.dic[@"TotalDiscount"]];
            
        }else if (indexPath.row == 14){
            cell.titleName.text = @"总成本";
            cell.detailName.text = [NSString stringWithFormat:@"¥%@",self.dic[@"TotalCost"]];
            
        }else if (indexPath.row == 15){
            cell.titleName.text = @"总利润";
            cell.detailName.text = [NSString stringWithFormat:@"¥%@",self.dic[@"TotalProfit"]];
            
        }else if (indexPath.row == 16){
            cell.titleName.text = @"利润比";
            cell.detailName.text =self.dic[@"ProfitRatio"];
            
        }else if (indexPath.row == 17){
            cell.titleName.text = @"欠款";
            cell.detailName.text = [NSString stringWithFormat:@"¥%@",self.dic[@"Arrears"]];
            
        }else if (indexPath.row == 18){
            cell.titleName.text = @"报修时间";
            cell.detailName.text =self.dic[@"RepairTime"];
            
        }else if (indexPath.row == 19){
            cell.titleName.text = @"结算时间";
            cell.detailName.text =self.dic[@"SettlementTime"];
            
        }


    }
}
@end
